package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
	"github.com/zeromicro/go-zero/core/logx"
)

type AppConfig struct {
	MysqlConfig
	RealName
	Jwt
}
type MysqlConfig struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type RealName struct {
	SecretId  string
	SecretKey string
}
type Jwt struct {
	AccessSecret string
}

var AppConf AppConfig

func ConfigInit() {
	viper.SetConfigFile("../user_srv/appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		logx.Info("配置读取信息失败", err)
		return
	}
	logx.Info("配置读取信息成功")
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		logx.Info("配置解析信息失败", err)
		return
	}
	logx.Info("配置解析信息成功")
	fmt.Println(AppConf)
}
